<template>
  <div>
    <el-dialog id="chooseCategoryDialog" title="发卡" v-model="openFlag" width="400px" append-to-body>
      <div class="ui_el_dialog_body">
        <el-form ref="form" :model="formData" :rules="rules" label-width="auto">
          <el-form-item label="资产编码">
            <el-input disabled v-model="currentRow.number" />
          </el-form-item>
          <el-form-item label="资产名称">
            <el-input disabled v-model="currentRow.name" />
          </el-form-item>
          <el-form-item label="RFID">
            <el-input v-model="currentRow.rfid" />
          </el-form-item>
        </el-form>
      </div>
      <template #footer>
        <div class="ui_el_dialog_footer">
          <el-button @click="close">取消</el-button>
          <el-button type="primary" style="color: #fff; background-color: #005bf5;" @click="subData">提交</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>

import api from "./api.js";
import RfidDialog from "@/components/RFID/RfidDialog.vue";

const rfidDialog = ref();

const { proxy } = getCurrentInstance();

const openFlag = ref(false);
const currentRow = reactive({});

const emit = defineEmits(['sub']);

function open(row) {
  Object.assign(currentRow, row);
  openFlag.value = true;
}

function close() {
  openFlag.value = false;
}

function readTag() {
  rfidDialog.value.open();
}

function afterChooseTag(tag) {

  currentRow.rfid = tag;
}

function subData() {

  api.updateAssetItem(currentRow).then(() => {
    proxy.$modal.msgSuccess("修改成功");
    openFlag.value = false;
    emit('sub');
  });
}

defineExpose({
  open
})


</script>

<style lang="scss">
.send-card-row {
  display: flex;
}
</style>